<?php
/**
 * 我的账单
 * User: tengyu
 * Date: 2017/8/31
 * Time: 16:50
 */?>
@extends('common.common')
@section('title','账单-个人中心')
@section('css')
    <link rel="stylesheet" href="{{asset('/css/personal_bill.css')}}">
    <link rel="stylesheet" href="{{asset('/css/date.css')}}">
    <link rel="stylesheet" href="{{asset('/css/dateDefault.css')}}">
@endsection
@section('js')
    <script type="text/javascript" src="{{asset('/js/laydate.dev.js')}}"></script>
    <script type="text/javascript">
        laydate({
            elem: '#date'
        });
        laydate({
            elem: '#datem'
        });
        laydate({
            elem: '#datez'
        });
        function pageNow(page_act)
        {
            var pageNow = $("input[name='pageNow']").val();
            var pageNum = $("input[name='pageNum']").val();
            $.ajax({
                url:'/user/bill_months',
                type:'get',
                dataType:'json',
                data:{'pageNum':pageNum,'pageNow':pageNow,'page_act':page_act},
                success:function(res){
                    if(res.msg=='查询分页成功'){
                        var da = eval(res.data);
                        $("input[name='month_time']").val(da['0'].months);
                        var html = '';
                        for(var i=0;da.length>i;i++){
                            if(i=='0'){
                                html+='<li class=active>';
                            }else{
                                html+='<li>';
                            }
                            html+='<a href="/user/bill?month_time='+da[i].months+'">';
                            html+='<span class="year_month">'+da[i].months+'</span>&nbsp;<span>¥'+da[i].amounts+'&nbsp;</span></a>';
                            html+='</li>';
                        }
                        html += '<li class="upDown">';
                        html += '<i class="glyphicon glyphicon-chevron-left" onclick="pageNow('+"'"+res.param['page_act_prev']+"'"+')"></i>';
                        html += '<i class="glyphicon glyphicon-chevron-right" onclick="pageNow('+"'"+res.param['page_act_next']+"'"+')"></i></li>';
                        $("#select_bill_months").html(html);
                        window.location = '/user/bill?month_time=' + da[0].months;
                    } else{
                        alert(res.msg);
                    }
                },
                error:function(){
                    console.log('数据不通过');
                }
            });
        }
    </script>
@endsection
@section('content')
    <div id="content">
        <!--nav start-->
        @include('common.centernav')
        <!--nav end-->
        <h3>个人中心</h3>
        <div class="container">
            <div class="row">
                @include('usercenter.usersidebar')
                <!--2、右侧主体-->
                <div class="col-xs-9">
                    <!--右侧面版-->
                    <div id="panel" class="panel panel-default rightPanel">
                        <div class="panel-heading">
                        <h4>我的账单
                            @if(!empty($param['bill_months']))
                            <a class="rt" href="javascript:void(0);" id="repay_all">一键还款</a>
                            @endif
                        </h4>
                        </div>
                        <input type="hidden" name="month_time"  value="{{$param['month_time']}}">
                        <input type="hidden" name="pageNum" value="{{$param['pageNum']}}">
                        <input type="hidden" name="pageNow" value="{{$param['pageNow']}}">
                        @if(count($param['bill_months'])>0)
                        <div class="panel-body">
                            <ul class="nav nav-tabs" id="select_bill_months">
                                @foreach($param['bill_months'] as $k=>$v)
                                @if($param['month_time']==$v->months)<li class="active">@else<li>@endif
                                <a href="{{url('/user/bill?month_time='.$v->months)}}"><span class="year_month">{{$v->months}}</span>&nbsp;<span>¥{{$v->amounts}}&nbsp;</span></a>
                                </li>
                                @endforeach
                                <li class="upDown">
                                    <i class="glyphicon glyphicon-chevron-left" onclick="pageNow('prev')"></i><!--上一页-->
                                    <i class="glyphicon glyphicon-chevron-right" onclick="pageNow('next')"></i><!--下一页-->
                                </li>
                            </ul><br/>
                            <div class="tab-content active">
                                <div>
                                    <ul class="list-inline">
                                        <li>付款日</li>
                                        <li><input type="text" name="pay_bill_months" id="date"></li>
                                        <li><button onclick="alert('设置付款日')">点击确认付款日</button></li>
                                        <li class="pull-right">未付款<span>@if(!empty($param['bill_status_wait'][0]->amounts))¥{{$param['bill_status_wait'][0]->amounts}}@else{{'0'}}@endif</span></li>
                                        <li class="pull-right">本期已付款<span>@if(!empty($param['bill_status_finish'][0]->amounts))¥{{$param['bill_status_finish'][0]->amounts}}@else{{'0'}}@endif</span></li>
                                    </ul>
                                </div>
                            </div>
                                @foreach($param['bill_month_list'] as $k=>$v)
                                <ul class="orders list-inline">
                                    <li class="imgInfo">
                                    <div class="media">
                                        <div class="media-left">
                                            <img src="{{asset(env('STATIC_FILE_ERP_PATH').$v->fitment_dt_img)}}" style="width: 151px;height: 92px;">
                                        </div>
                                        <div class="media-body">
                                            <p>{{$v->fitments_name}}</p>
                                            <p><img src="{{$param['color'][$v->color_type]}}" alt="当前家具颜色"></p>
                                            <p>¥<span>{{$v->price}}</span>/月</p>
                                        </div>
                                    </div>
                                    </li>
                                    <li>¥{{$v->amount}}</li>
                                    <li>{{date('Y-m-d',strtotime($v->rent_start_date))}}</li>
                                    <li><span>@if($v->status==1){{'已付款'}}@else{{'未付款'}}@endif</span></li>
                                </ul>
                                @endforeach
                            <div class="text-right">{{ $param['bill_month_list']->appends(['month_time'=>$param['month_time']]) }}</div>
                        </div>
                    </div>
                    @else
                    <div class="text-center">
                        <img src="{{asset('/img/771509094256_.pic.jpg')}}" alt="暂无数据">
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
<!--隔断底部-->
<div id="partition"></div>
<script>
    $("#repay_all").click(function(){
        alert('一键还款页');
    });
</script>
@endsection
